{{include file="header.tpl"}}
<div class="w1002 borrow_nav">
标题：{{$res.TITLE}}<br/>
文章内容：{{$res.CONTENT}}

<br/>
{{foreach from=$comres.data item=item key=key}}
{{$key+1}}楼
评论人：{{$item.USERNAME}}
评论内容：{{$item.COMMENT}}
{{if $item.PARENTID!=0}}{{$item.PNAME}}评论{{$item.USERNAME}}{{else}}{{/if}}
{{if !$user.USERNAME}}
  您没有评论的权限！
{{else}}
<input type="button" onclick="pl({{$item.ID}},{{$item.USERID}});" name="" value="评论">
<div id="pinglun"></div>
{{/if}}
<br/>
{{foreachelse}}
尚未有人评论？
{{/foreach}}
{{$comres.page}}
</div>
{{if $res.CATID==15 || $res.IS_COMMENT==1}}
    <form action="index.php?ctl=article&act=Save" method="post" id="queform" name="queform">
        <table width="100%" border="0" cellspacing="1" cellpadding="0" class="table_list">
             <tr><td colspan="10">内容：<textarea name="comment" cols="80" rows="8" id="content"></textarea></td></tr>
             {{if $user.USERNAME}}
<!--             <input type="hidden" name="parentid" value="{{$smarty.request.id}}">-->
             <input type="hidden" name="dataid" value="{{$smarty.request.id}}">
              <input type="hidden" name="userid" value="{{$user.ID}}">
              <tr><td colspan="10"><input type="button" name="submit" id="subloan" value="提交"></td></tr>
             {{else}}
             <tr><td colspan="10">您没有评论的权限，请先登录！</td></tr>  
             {{/if}}
        </table>   
    </form>
{{/if}}
<script type="text/javascript">
      $('#subloan').click(function(){
            if($('#comment').val()!=""){
                var param = $('#queform').serialize();
//                $.jBox.tip('正在申请...','loading');
                $.post("index.php?ctl=article&act=Save",param,function(res){
                    var submit =function(v,g,f){
                    if(v == "ok")
                         window.open(res.tourl,"_top");                         
                    }
                    if(res.code == 'success'){
                        $.jBox.confirm("提交评论成功。","提示",submit);
                       
                    }else{
                        $.jBox.confirm(res.msg,"提示",submit);
                    }
                },"json");          
            }
            else if($('#comment').val()==""){
                $.jBox.alert('请填写内容','提示');
            }
            return false;
            
        });
        function pl(parentid,userid){
        var html='';
        html='<form action="" method="post" name="qform" id="qform">';
        html+='<input type="hidden" name="parentid" id="" value="'+parentid+'">';
        html+='<input type="hidden" name="dataid" id="" value="'+{{$smarty.request.id}}+'">';
        html+='<input type="hidden" name="userid" id="" value="'+ userid +'">';
        html+='<input type="text" name="comment" id="comment">';
        html+='<input type="button" name="sbutton" id="sbutton" value="提交" onclick="submitpl();">';
        html+='</form>'
        $('#pinglun').html(html);
        };
        function submitpl(){
            if($('#comment').val()!=""){
                var param = $('#qform').serialize();
//                $.jBox.tip('正在申请...','loading');
                $.post("index.php?ctl=article&act=Save",param,function(res){
                    var submit =function(v,g,f){
                    if(v == "ok")
                         window.open(res.tourl,"_top");                         
                    }
                    if(res.code == 'success'){
                        $.jBox.confirm("提交评论成功。","提示",submit);
                       
                    }else{
                        $.jBox.confirm(res.msg,"提示",submit);
                    }
                },"json");          
            }
            else if($('#comment').val()==""){
                $.jBox.alert('请填写内容','提示');
            }
            return false;
            
        };
</script>
{{include file="footer.tpl"}}